import { PrismaClient } from '@prisma/client';
import * as bcrypt from 'bcrypt';

const prisma = new PrismaClient();

async function checkUsers() {
  try {
    const users = await prisma.user.findMany({
      where: {
        role: 'ADMIN'
      }
    });

    console.log(`\n找到 ${users.length} 个管理员账号:\n`);

    for (const user of users) {
      console.log(`--- 管理员 ${user.id} ---`);
      console.log('  用户名:', user.username);
      console.log('  昵称:', user.nickname);
      console.log('  openid:', user.openid);

      if (user.password) {
        const isValid = await bcrypt.compare('admin123', user.password);
        console.log('  密码 "admin123":', isValid ? '✅ 正确' : '❌ 错误');
      } else {
        console.log('  密码: ❌ 为空');
      }
      console.log('');
    }

  } catch (error) {
    console.error('查询失败:', error);
  } finally {
    await prisma.$disconnect();
  }
}

checkUsers();
